<?php
namespace app\adminapiv3\controller;
use app\common\model\FilePath;
use think\Request;

/**
 * @name: 首页
 * @Param: 
 * @Description: 
 * @Author: foo
 * @Date: 2019-10-22 17:34:56
 */

class Index extends Base
{

    /**
     * @name 排行榜
     * @author wx
     * @date 2020/10/27 15:05
     */
    public function rand(Request $request)
    {
        $token = $request->accesstoken;

        $server = new \app\adminapiv3\service\Index();
        $list = $server->rand($token);

        $this->jsonOutPut($list);
    }

    /**
     * @name 主机资源使用率
     * @author wx
     * @date 2020/6/1 9:25
     */
    function hostResource()
    {
        $server = new \app\adminapiv3\service\Index();
        $info = $server->hostResource();

        $this->jsonOutPut($info);
    }

    /**
     * @name 网络攻击占比
     * @author wx
     * @date 2020/6/1 9:34
     */
    function attackRatio()
    {
        $server = new \app\adminapiv3\service\Index();
        $data = $server->attackRatio();

        $this->jsonOutPut($data);
    }

    /**
     * @name 判断是否安装
     * @author wx
     * @date 2019/12/10 15:10
     */
    function isInstall()
    {
        $filePathServer = new FilePath();
        $installFileName = $filePathServer->install_path;
        $systemTimeFile = $filePathServer->system_time;

        if (file_exists($installFileName) && file_exists($systemTimeFile)) {
            $data['is_install'] = 1;//未安装
        }else{
            $data['is_install'] = 0;//已安装
        }


        $this->jsonOutPut($data);
    }
    
}